package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.core.Result;
import com.dongdongshop.core.ResultEnum;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.ContentService;
import com.dongdongshop.util.PageBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("contentController")
public class ContentController {

    //开启日志
    Logger logger = LoggerFactory.getLogger(ContentController.class);

    @Reference(check=false ,timeout=106666)
    private ContentService contentService;

    //广告查询，通过前台传过来的categoryId分类id可以动态的查询不同分类广告的数据
    @RequestMapping("getContentBannerInfo")
    @ResponseBody
    public Result getBrandInfo(Long categoryId){
        try {
            logger.info("广告查询方法开始运行{}");
            List<TbContent> contents = contentService.getContentBannerInfo(categoryId);
            return Result.response(ResultEnum.SUCCESS).setData(contents);
        }catch (Exception e){
            Result.response(ResultEnum.ERROR);
            logger.error("出现错误，查看日志{}",e);
        }
        return Result.response(ResultEnum.SUCCESS);
    }
}
